/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package homomorphism;

import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
import utility.LongPair;

/**
 *
 * @author takeshi
 */
    public  class GroupLongPairComparator  extends WritableComparator {
//     public  class GroupLongPairComparator implements RawComparator<LongPair>{

        protected GroupLongPairComparator() {
            super(LongPair.class);
        }

    @Override
        public int compare(WritableComparable  w1, WritableComparable  w2) {
            LongPair ip1 = (LongPair) w1;
            LongPair ip2 = (LongPair) w2;
            return LongPair.compare(ip1.getFirst(), ip2.getFirst());
        }

        public int compare(LongPair w1, LongPair w2) {
            LongPair ip1 =  w1;
            LongPair ip2 =   w2;
            return LongPair.compare(ip1.getFirst(), ip2.getFirst());
        }

    @Override
        public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
                return WritableComparator.compareBytes(b1, s1, Long.SIZE/8,
                                             b2, s2, Long.SIZE/8);
        }
    }
